package com.njtoyo.taxi.admin.mapper.master.mapper;

import cn.hutool.core.date.DateTime;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njtoyo.taxi.admin.library.Const;
import com.njtoyo.taxi.admin.mapper.master.entity.RideOrder;
import com.njtoyo.taxi.admin.mapper.master.enums.RideOrderState;
import com.njtoyo.taxi.admin.mapper.secondary.entity.OrderBankBill;
import com.njtoyo.taxi.admin.rest.export.customer.CustomerArrearsExportPresenter;
import com.njtoyo.taxi.admin.rest.presenter.business.driver.DriverQueryRideClickFarmingDto;
import com.njtoyo.taxi.admin.rest.presenter.business.ride.RideListPresenter;
import com.njtoyo.taxi.admin.rest.presenter.business.ride.RideListPresenterDTO;
import com.njtoyo.taxi.admin.rest.presenter.customer.CustomerArrearsListPresenter;
import com.njtoyo.taxi.admin.rest.presenter.finance.vo.FinanceAllowanceStatsCountVo;
import com.njtoyo.taxi.admin.rest.wrapper.business.customer.CustomerArrearsExportWrapper;
import com.njtoyo.taxi.admin.rest.wrapper.business.customer.CustomerArrearsQueryWrapper;
import com.njtoyo.taxi.admin.rest.wrapper.business.driver.GetRideClickFarmingDto;
import com.njtoyo.taxi.admin.rest.wrapper.business.ride.OrderManageQueryDto;
import com.njtoyo.taxi.admin.rest.wrapper.business.ride.RideQueryWrapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author Dell
 * @since 2021-07-26
 */
@Repository
@DS(Const.PRIMARY_DS)
public interface RideOrderMapper extends BaseMapper<RideOrder> {
    BigDecimal computeDriverBalance(Long driverId);

    List<DriverQueryRideClickFarmingDto> getRideOrAmountCountForRideClickFarming(GetRideClickFarmingDto wrapper);

    Page<CustomerArrearsListPresenter> getRideOrderForArrearsList(CustomerArrearsQueryWrapper wrapper);

    List<CustomerArrearsExportPresenter> exportRideOrderForArrearsList(CustomerArrearsExportWrapper wrapper);

    Page<CustomerArrearsListPresenter> getAllForArrearsList(CustomerArrearsQueryWrapper wrapper);

    List<CustomerArrearsExportPresenter> exportAllForArrearsList(CustomerArrearsExportWrapper wrapper);

    List<FinanceAllowanceStatsCountVo> selectOnlineRideCount(@Param("startDate") Date startDate, @Param("endDate") Date endDate);

    BigDecimal selectDriverFundsIn(@Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);

    BigDecimal selectDriverUndrawnBalanceAmountIn(@Param("endTime") DateTime endTime);

    BigDecimal selectFinancePaymentPlatformFeeAli(@Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);

    BigDecimal selectFinancePaymentPlatformFeeWechat(@Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);

    BigDecimal selectFinancePaymentPlatformFeeWxmina(@Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);

    BigDecimal selectFinancePaymentPlatformFeeUnionPay(@Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);


    IPage<RideListPresenterDTO> getSuspiciousPage(Page<RideListPresenterDTO> page, @Param("query") RideQueryWrapper query);

    List<RideOrder> selectArrearOrdes(@Param("userId") Long userId);

    List<Map<String, Object>> getRideAndSimpleOrder(@Param("startDate") Date startDate, @Param("endDate") Date endDate);

    List<Map<String, Object>> selectAmountByCompany(@Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("companyIds") List<Long> companyIds);

    List<Map<String, Object>> selectByHour(@Param("state") RideOrderState rideOrderState, @Param("startDate") Date todayStart, @Param("endDate") Date todayEnd, @Param("cantonId") Integer cantonId);

    List<Map<String, Object>> selectFinishByDay(@Param("cantonId") Integer cantonId, @Param("startDate") Date todayStart, @Param("endDate") Date todayEnd);

    BigDecimal comIncome();

    BigDecimal getInfoServiceAmount(@Param("startDate") Date startDateTime, @Param("endDate") Date endDateTime);

    //异常单
    List<RideListPresenterDTO> getAbnormalList(@Param("query") OrderManageQueryDto wrapper);

    BigDecimal sumAmountByCompany(@Param("companyIds") List<Long> companyIds);
}
